#include <../../../../../libraries/Wire/Wire.h>

#include <inttypes.h>

#define  MODE_REG   0x00
#define  PULLUP_REG 0x06
#define  VALUE_REG  0x09

#define MCP23009_INPUT_MODE 1
#define MCP23009_OUTPUT_MODE 0
#define MCP23009_PULLUP_ON 1
#define MCP23009_PULLUP_OFF 0

class mcp23009
{
  public:
    void init(uint8_t addr);
    void reset();
    void set_mode(uint8_t port, uint8_t val);
    void set_pullup(uint8_t port, uint8_t val);
    void set_value(uint8_t port, uint8_t val);
    uint8_t get_value(uint8_t port);
  private:
    uint8_t _addr;
    uint8_t _mode;
    uint8_t _pullup;
    uint8_t _value;
    void send_data(uint8_t register, uint8_t val);
};
